package com.shop.admin.dao.user;

import com.shop.jpa.BaseDao;
import com.shop.domain.user.UserPinkBill;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

@Repository
public interface UserPinkBillDao extends BaseDao<UserPinkBill, Long> {

    //未中奖 添加佣金记录流水
    @Modifying(clearAutomatically = true)
    @Query(value = "insert into t_user_pink_bill(uid,link_id,pink_id,initial_price,price,refresh_price,pm,table_name,create_time) " +
            "select p.uid,p.id,p.pink_id,u.brokerage,c.ret_price,u.brokerage+c.ret_price,0,'store_pink',now() from t_store_pink p " +
            "left join t_user u on u.id = p.uid left join t_store_pink_config c on c.id = p.pink_id " +
            "where p.pink_id=?1 and p.pink_status = 2 and p.`status`=1 and p.`is_deleted` =0",nativeQuery = true)
    int addNotPzUserBill(Long pink_id);
}
